import { get_without_param, post_with_json, put_with_json, delete_with_param } from './HttpMethod';

// 字典类型接口
export interface DictType {
  id?: string;
  name: string;
  code: string;
  description?: string;
  enabled?: number; // 0表示启用，1表示不启用
  sort?: number;
  icon?: string;
  color?: string;
  createDate?: string;
  updateDate?: string;
  createBy?: string;
  updateBy?: string;
  remark?: string;
}

// 字典数据接口
export interface DictData {
  id?: string;
  typeId: string;
  name: string;
  code: string;
  value: string;
  enabled?: number; // 0表示启用，1表示不启用
  sort?: number;
  icon?: string;
  color?: string;
  description?: string;
  createDate?: string;
  updateDate?: string;
  createBy?: string;
  updateBy?: string;
  remark?: string;
}

// 字典类型API
export const getDictTypeList = () => get_without_param('/api/dict-type/list');
export const getDictTypeListEnabled = () => get_without_param('/api/dict-type/list-enabled');
export const getDictTypeById = (id: string) => get_without_param(`/api/dict-type/${id}`);
export const getDictTypeByCode = (code: string) => get_without_param(`/api/dict-type/code/${code}`);
export const saveDictType = (data: DictType) => post_with_json('/api/dict-type/save', data);
export const updateDictType = (data: DictType) => put_with_json('/api/dict-type/update', data);
export const deleteDictType = (id: string) => delete_with_param(`/api/dict-type/${id}`);
export const deleteDictTypeByCode = (code: string) => delete_with_param(`/api/dict-type/code/${code}`);

// 字典数据API
export const getDictDataByTypeId = (typeId: string) => get_without_param(`/api/dict-data/type/${typeId}`);
export const getDictDataByTypeCode = (typeCode: string) => get_without_param(`/api/dict-data/type-code/${typeCode}`);
export const getDictDataEnabledByTypeId = (typeId: string) => get_without_param(`/api/dict-data/type/${typeId}/enabled`);
export const getDictDataEnabledByTypeCode = (typeCode: string) => get_without_param(`/api/dict-data/type-code/${typeCode}/enabled`);
export const getDictDataById = (id: string) => get_without_param(`/api/dict-data/${id}`);
export const getDictDataByCode = (code: string) => get_without_param(`/api/dict-data/code/${code}`);
export const getDictDataByValue = (value: string) => get_without_param(`/api/dict-data/value/${value}`);
export const saveDictData = (data: DictData) => post_with_json('/api/dict-data/save', data);
export const updateDictData = (data: DictData) => put_with_json('/api/dict-data/update', data);
export const deleteDictData = (id: string) => delete_with_param(`/api/dict-data/${id}`);
export const deleteDictDataByTypeId = (typeId: string) => delete_with_param(`/api/dict-data/type/${typeId}`);
